﻿<prism:VisualStateAwarePage
    x:Name="pageRoot"
    x:Class="WinRT.SIP.UI.Views.DialerPage"
    DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:WinRT.SIP.UI.Views"
    xmlns:common="using:WinRT.SIP.UI.Common"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:prism="using:Microsoft.Practices.Prism.StoreApps"
    mc:Ignorable="d"
    prism:ViewModelLocator.AutoWireViewModel="True">
    <!--
        This grid acts as a root panel for the page that defines two rows:
        * Row 0 contains the back button and page title
        * Row 1 contains the rest of the page layout
    -->
    <Grid Style="{StaticResource LayoutRootStyle}">
        <Grid.RowDefinitions>
            <RowDefinition Height="140"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="Auto"/>
        </Grid.ColumnDefinitions>

        <!-- Back button and page title -->
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>

            <Button x:Name="backButton"
                    AutomationProperties.AutomationId="DialerPageGoBackButton"
                    Command="{Binding GoBackCommand}"
                    Style="{StaticResource BackButtonStyle}" />
            <TextBlock x:Name="pageTitle" Grid.Column="1" Text="{StaticResource AppName}" Style="{StaticResource PageHeaderTextStyle}"/>
        </Grid>
        <StackPanel Width="300" HorizontalAlignment="Left" Grid.Row="1" Grid.Column="1" Margin="10,30,0,0">
            <TextBlock Margin="0,0,0,9" Text="Incoming Text:" Style="{StaticResource SubheaderTextStyle}" />
            <TextBlock Margin="0,0,0,9" HorizontalAlignment="Stretch" TextAlignment="Center" Text="{Binding TextMessage}" Style="{StaticResource HeaderTextStyle}" />
            <TextBlock Margin="0,0,0,9" Text="Outgoing Text:" Style="{StaticResource SubheaderTextStyle}" />
            <TextBox Margin="0,0,0,9" HorizontalAlignment="Stretch" TextAlignment="Center" Text="{Binding SendTextMessage, Mode=TwoWay}" />
        </StackPanel>

        <StackPanel Width="300" HorizontalAlignment="Left" Grid.Row="1" Grid.Column="0" Margin="120,30,0,0">
            <TextBlock Margin="0,0,0,9" Text="Call" Style="{StaticResource SubheaderTextStyle}" />
            <TextBlock Margin="0,0,0,9" HorizontalAlignment="Stretch" TextAlignment="Center" Text="{Binding PhoneNumber}" Style="{StaticResource HeaderTextStyle}" />
            <Grid Background="{StaticResource FlyoutBackground}">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>

                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>

                <Button HorizontalAlignment="Stretch" Command="{Binding DialOneCommand}" Style="{StaticResource LightButtonStyle}">
                    <StackPanel>
                        <TextBlock Text="1" HorizontalAlignment="Center" FontSize="48" FontWeight="Light" />
                        <TextBlock Text="" />
                    </StackPanel>
                </Button>

                <Button Grid.Column="1" HorizontalAlignment="Stretch" Command="{Binding DialTwoCommand}" Style="{StaticResource LightButtonStyle}">
                    <StackPanel>
                        <TextBlock Text="2" HorizontalAlignment="Center" FontSize="48" FontWeight="Light" />
                        <TextBlock Text="ABC" HorizontalAlignment="Center" />
                    </StackPanel>
                </Button>

                <Button Grid.Column="2" HorizontalAlignment="Stretch" Command="{Binding DialThreeCommand}" Style="{StaticResource LightButtonStyle}">
                    <StackPanel>
                        <TextBlock Text="3" FontSize="48" HorizontalAlignment="Center" FontWeight="Light" />
                        <TextBlock Text="DEF" HorizontalAlignment="Center" />
                    </StackPanel>
                </Button>

                <Button Grid.Row="1" HorizontalAlignment="Stretch" Command="{Binding DialFourCommand}" Style="{StaticResource LightButtonStyle}">
                    <StackPanel>
                        <TextBlock Text="4" HorizontalAlignment="Center" FontSize="48" FontWeight="Light" />
                        <TextBlock Text="GHI" HorizontalAlignment="Center" />
                    </StackPanel>
                </Button>

                <Button Grid.Row="1" Grid.Column="1" HorizontalAlignment="Stretch" Command="{Binding DialFiveCommand}" Style="{StaticResource LightButtonStyle}">
                    <StackPanel>
                        <TextBlock Text="5" HorizontalAlignment="Center" FontSize="48" FontWeight="Light" />
                        <TextBlock Text="JKL" HorizontalAlignment="Center" />
                    </StackPanel>
                </Button>

                <Button Grid.Row="1" Grid.Column="2" HorizontalAlignment="Stretch" Command="{Binding DialSixCommand}" Style="{StaticResource LightButtonStyle}">
                    <StackPanel>
                        <TextBlock Text="6" HorizontalAlignment="Center" FontSize="48" FontWeight="Light" />
                        <TextBlock Text="MNO" HorizontalAlignment="Center" />
                    </StackPanel>
                </Button>

                <Button Grid.Row="2" HorizontalAlignment="Stretch" Command="{Binding DialSevenCommand}" Style="{StaticResource LightButtonStyle}">
                    <StackPanel>
                        <TextBlock Text="7" HorizontalAlignment="Center" FontSize="48" FontWeight="Light" />
                        <TextBlock Text="PQRS" HorizontalAlignment="Center" />
                    </StackPanel>
                </Button>

                <Button Grid.Row="2" Grid.Column="1" HorizontalAlignment="Stretch" Command="{Binding DialEightCommand}" Style="{StaticResource LightButtonStyle}">
                    <StackPanel>
                        <TextBlock Text="8" HorizontalAlignment="Center" FontSize="48" FontWeight="Light" />
                        <TextBlock Text="TUV" HorizontalAlignment="Center" />
                    </StackPanel>
                </Button>

                <Button Grid.Row="2" Grid.Column="2" HorizontalAlignment="Stretch" Command="{Binding DialNineCommand}" Style="{StaticResource LightButtonStyle}">
                    <StackPanel>
                        <TextBlock Text="9" HorizontalAlignment="Center" FontSize="48" FontWeight="Light" />
                        <TextBlock Text="WXYZ" HorizontalAlignment="Center" />
                    </StackPanel>
                </Button>

                <Button Grid.Row="3" HorizontalAlignment="Stretch" Command="{Binding DialAsteriskCommand}" Style="{StaticResource LightButtonStyle}">
                    <StackPanel>
                        <TextBlock Text="*" HorizontalAlignment="Center" FontSize="48" FontWeight="Light" />
                        <TextBlock Text="" HorizontalAlignment="Center" />
                    </StackPanel>
                </Button>

                <Button Grid.Row="3" Grid.Column="1" HorizontalAlignment="Stretch" Command="{Binding DialZeroCommand}" Style="{StaticResource LightButtonStyle}">
                    <StackPanel>
                        <TextBlock Text="0" HorizontalAlignment="Center" FontSize="48" FontWeight="Light" />
                        <TextBlock Text="+" HorizontalAlignment="Center" />
                    </StackPanel>
                </Button>

                <Button Grid.Row="3" Grid.Column="2" HorizontalAlignment="Stretch" Command="{Binding DialPoundCommand}" Style="{StaticResource LightButtonStyle}">
                    <StackPanel>
                        <TextBlock Text="#" HorizontalAlignment="Center" FontSize="48" FontWeight="Light" />
                        <TextBlock Text="" />
                    </StackPanel>
                </Button>

            </Grid>
            <StackPanel Orientation="Horizontal">
                <Button Content="Text" Width="119" Command="{Binding TextCommand}" />
                <Button Content="Call" Margin="-3,0,0,0" Width="119" Command="{Binding CallCommand}" />
                <Button Content="&lt;" Width="62" Command="{Binding DeleteCommand}" />
            </StackPanel>
        </StackPanel>

        <VisualStateManager.VisualStateGroups>

            <!-- Visual states reflect the application's view state -->
            <VisualStateGroup x:Name="ApplicationViewStates">
                <VisualState x:Name="FullScreenLandscape"/>
                <VisualState x:Name="Filled"/>

                <!-- The entire page respects the narrower 100-pixel margin convention for portrait -->
                <VisualState x:Name="FullScreenPortrait">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PortraitBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>

                <!-- The back button and title have different styles when snapped -->
                <VisualState x:Name="Snapped">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="pageTitle" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedPageHeaderTextStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>
</prism:VisualStateAwarePage>
